//  订单列表
export const orderListColumns = [
  { width: 220, label: '订单号', prop: 'order_sn', fixed: 'left', field: 2 },
  { width: 220, label: '菜谱订单号', prop: 'package_menu_order_sn', field: 26 },
  { width: 220, label: '用户名称', prop: 'nickname', fixed: 'left', sort: 'custom', field: 3, slot: true },
  { label: '用户编码', prop: 'user_code', sort: 'custom', field: 4 },
  { width: 180, label: '下单日期', prop: 'created_at', field: 5 },
  { label: '配送日期', prop: 'send_time', sort: 'custom', field: 6 },
  { label: '下单原价', prop: 'origin_should_money', field: 7 },
  { label: '下单金额', prop: 'should_money', field: 8 },
  { label: '配送金额', prop: 'send_money', field: 9 },
  { label: '退货金额', prop: 'return_money', field: 10 },
  { label: '运费', prop: 'delivery_fee', field: 11 },
  { label: '订单状态', prop: 'status', field: 12, slot: true },
  { label: '支付状态', prop: 'pay_status', field: 13, slot: true },
  { label: '支付方式', prop: 'is_prior_payment', field: 14, slot: true },
  { label: '业务员', prop: 'salesman_id', field: 15 },
  { label: '司机', prop: 'driver', field: 16 },
  { label: '线路', prop: 'line', field: 17 },
  { label: '来源', prop: 'userNickname', field: 18, slot: true },
  { label: '子账号', prop: 'zid', field: 19 },
  { label: '打印', prop: 'is_print', field: 20, slot: true },
  { label: '收货人', prop: 'contact', field: 21 },
  { width: 130, label: '收货手机', prop: 'mobile', field: 22 },
  { width: 200, label: '收货地址', prop: 'address', field: 23 },
  { label: '备注', prop: 'remark', field: 24 },
  { label: '回单', prop: 'returnOrder', field: 25, slot: true },
]

// 订单退货
export const orderReturnColumns = [
  { width: 160, showOverflowTooltip: true, label: '用户名称', prop: 'nickname', slot: true },
  { width: 190, showOverflowTooltip: true, label: '退货单号', prop: 'order_sn' },
  { width: 120, showOverflowTooltip: true, label: '退货金额', prop: 'apply_money' },
  { width: 180, showOverflowTooltip: true, label: '关联订单', prop: 'related_order_sn' },
  { width: 120, showOverflowTooltip: true, label: '支付方式', prop: 'pay_type', slot: true },
  { width: 190, showOverflowTooltip: true, label: '关联入库单', prop: 'storage_order_sn' },
  { width: "auto", showOverflowTooltip: true, label: '退货原因', prop: 'return_remark' },
  { width: "auto", showOverflowTooltip: true, label: '申请时间', prop: 'time', slot: true },
  { width: "auto", showOverflowTooltip: true, label: '审核日期', prop: 'date', slot: true },
  { width: "auto", showOverflowTooltip: true, label: '状态', prop: 'order_pay_status', slot: true },
]

// 订单商品拆分
export const orderGoodsSpliutColumns = [
  { width: 260, label: '商品名称', prop: 'name' },
  { width: 100, label: '单位', prop: 'unit' },
  { width: 260, label: '分类', prop: 'category_name' },
  { width: 160, label: '下单数量', prop: 'order_num' },
  { width: 160, label: '下单单价', prop: 'order_price' },
  { width: "auto", label: '下单小计', prop: 'order_money' },
]

export function sortColumns(arr, arr2) {
  // 自定义排序函数
  arr.sort((a, b) => {
    // 获取a和b在sortOrder数组中的索引
    let indexA = arr2.indexOf(a.field);
    let indexB = arr2.indexOf(b.field);
  
    // 根据索引进行比较，如果索引不存在，则将该对象排序到数组末尾
    return indexA === -1 ? 1 : indexB === -1 ? -1 : indexA - indexB;
  });
  return arr
}